home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-19 / gpt32src.zip / EPSON.TRM < prev    next >
Text File  |  1992-03-25  |  12KB  |  486 lines

  1. /*
  2.  * $Id: epson.trm,v 3.26 92/03/24 22:34:52 woo Exp Locker: woo $
  3.  */
  4.  
  5. /* GNUPLOT - epson.trm */
  6. /*
  7.  * Copyright (C) 1990, 1991, 1992   
  8.  *
  9.  * Permission to use, copy, and distribute this software and its
  10.  * documentation for any purpose with or without fee is hereby granted, 
  11.  * provided that the above copyright notice appear in all copies and 
  12.  * that both that copyright notice and this permission notice appear 
  13.  * in supporting documentation.
  14.  *
  15.  * Permission to modify the software is granted, but not the right to
  16.  * distribute the modified code.  Modifications are to be distributed 
  17.  * as patches to released version.
  18.  *  
  19.  * This software  is provided "as is" without express or implied warranty.
  20.  * 
  21.  * This file is included by ../term.c.
  22.  *
  23.  * This terminal driver supports:
  24.  *  epson_lx800, nec_cp6c, nec_cp6d, nec_cp6b, starc,
  25.  *  epson_60dpi, tandy_60dpi
  26.  *
  27.  * AUTHORS
  28.  *  Russell Lang
  29.  *  William Wilson
  30.  *
  31.  * send your comments or suggestions to (info-gnuplot@ames.arc.nasa.gov).
  32.  * 
  33.  */
  34.  
  35. /* The following epson lx800 driver uses generic bit mapped graphics
  36.    routines to build up a bit map in memory. */
  37. /* by Russell Lang, rjl@monu1.cc.monash.edu.au */
  38. /* On PC, print using 'copy file /b lpt1:', do NOT use 'print' */
  39. /* EPSON_init changes outfile to binary mode on PC's */
  40.  
  41. #ifdef EPSONP
  42.  
  43. #define EPSONXMAX    512 
  44. #define EPSONYMAX    384
  45.  
  46. #define EPSONXLAST (EPSONXMAX - 1)
  47. #define EPSONYLAST (EPSONYMAX - 1)
  48.  
  49. #define EPSONVCHAR        FNT5X9_VCHAR      
  50. #define EPSONHCHAR        FNT5X9_HCHAR        
  51. #define EPSONVTIC        6
  52. #define EPSONHTIC        6
  53.  
  54. EPSONinit()
  55. {
  56. #ifdef PC
  57.     reopen_binary();
  58. #endif
  59. #ifdef vms
  60.     reopen_binary();
  61. #endif
  62. }
  63.  
  64.  
  65. EPSONgraphics()
  66. {
  67.     b_charsize(FNT5X9);
  68.     b_makebitmap((unsigned int)(EPSONXMAX*xsize),
  69.                  (unsigned int)(EPSONYMAX*ysize),1);
  70. }
  71.  
  72.  
  73. EPSONtext()
  74. {
  75.     epson_dump();
  76.     b_freebitmap();
  77. }
  78.  
  79.  
  80. #define EPSONlinetype b_setlinetype
  81. #define EPSONmove b_move
  82. #define EPSONvector b_vector
  83. #define EPSONput_text b_put_text
  84. #define EPSON_text_angle b_text_angle
  85.  
  86. EPSONreset()
  87. {
  88. #ifdef vms
  89.     fflush_binary();
  90. #endif
  91. }
  92.  
  93.  
  94. /* output file must be binary mode for epson_dump */
  95. epson_dump()
  96. {
  97.   register unsigned int x;
  98.   int j;
  99.     for (j=(b_ysize/8)-1; j>=0; j--) {
  100.         /* select plotter graphics mode (square pixels) */
  101.         fprintf(outfile,"\033J\030");    /* line feed 8/72" = 8 dots */
  102.         fprintf(outfile,"\r\033*\005");
  103.         (void) fputc((char)(b_xsize%256),outfile);
  104.         (void) fputc((char)(b_xsize/256),outfile);
  105.         for (x=0; x<b_xsize; x++) {
  106.             (void) fputc( (char)(*((*b_p)[j]+x)), outfile );
  107.         }
  108.     }
  109. #ifdef PC
  110.     fprintf(stderr,"Print using: COPY /B\n");
  111. #endif
  112. }
  113.  
  114. #endif /* EPSONP */
  115.  
  116.  
  117. /* The following NEC CP6 Pinwriter driver uses generic bit mapped graphics
  118.    routines to build up a bit map in memory. */
  119. /* by Russell Lang, rjl@monu1.cc.monash.edu.au */
  120. /* On PC, print using 'copy file /b lpt1:', do NOT use 'print' */
  121. /* NECinit changes outfile to binary mode for PC's */
  122.  
  123. /* Add a Monochrome NEC printer (for faster speed and line types) jdc */
  124.  
  125. #ifdef NEC
  126.  
  127. #define NECXMAX    400 
  128. #define NECYMAX    320
  129.  
  130. #define NECXLAST (NECXMAX - 1)
  131. #define NECYLAST (NECYMAX - 1)
  132.  
  133. #define NECVCHAR        FNT5X9_VCHAR      
  134. #define NECHCHAR        FNT5X9_HCHAR        
  135. #define NECVTIC        6
  136. #define NECHTIC        6
  137.  
  138. /* plane 0=black, 1=cyan(blue), 2=magenta(red), 3=yellow */
  139. static unsigned int neccolor[] = {1,8,4,2,10,12,6,14};
  140. static unsigned int necpcolor[]= {0,2,1,4};
  141.  
  142. NECinit()
  143. {
  144. #ifdef PC
  145.     reopen_binary();
  146. #endif
  147. #ifdef vms
  148.     reopen_binary();
  149. #endif
  150. }
  151.  
  152.  
  153. /* Monochrome only NEC CP6 printer (set term nec_cp6m or nec_cp6d). */
  154. /* will probably work with NEC P6 printer */
  155. NECMgraphics()
  156. {
  157.     b_charsize(FNT5X9);
  158.     b_makebitmap((unsigned int)(NECXMAX*xsize),
  159.                  (unsigned int)(NECYMAX*ysize),1);
  160. }
  161.  
  162. /* Color ribbon in NEC CP6 printer (set term nec_cp6c) */
  163. NECCgraphics()
  164. {
  165.     b_charsize(FNT5X9);
  166.     b_makebitmap((unsigned int)(NECXMAX*xsize),
  167.                  (unsigned int)(NECYMAX*ysize),4);
  168. }
  169.  
  170.  
  171. NECdraft_text()
  172. {
  173.     nec_draft_dump();
  174.     b_freebitmap();
  175. }
  176.  
  177. NECtext()
  178. {
  179.     nec_dump();
  180.     b_freebitmap();
  181. }
  182.  
  183. NECClinetype(linetype)
  184. int linetype;
  185. {
  186.     if (linetype>=6)
  187.         linetype %= 6;
  188.     b_setvalue(neccolor[linetype+2]);
  189. }
  190.  
  191. #define NECMlinetype b_setlinetype
  192. #define NECmove b_move
  193. #define NECvector b_vector
  194. #define NECput_text b_put_text
  195. #define NEC_text_angle b_text_angle
  196.  
  197.     
  198. NECreset()
  199. {
  200. #ifdef vms
  201.     fflush_binary();
  202. #endif
  203. }
  204.  
  205.  
  206. /* output file must be binary mode for nec_dump */
  207. nec_dump()
  208. {
  209. unsigned int x;
  210. unsigned int plane,offset;
  211. int j;
  212. unsigned int column8;
  213. unsigned long column24;
  214. char column3, column2, column1;
  215.     fprintf(outfile,"\033P\033l\005");  /* 10cpi, left margin 5 char */
  216.     for (j=(b_ysize/8)-1;j>=0;j--) {
  217.             fprintf(outfile,"\033J\030");  /* 24/180" line feed */
  218.             for (plane=0; plane<b_planes; plane++) {
  219.                 offset=plane*b_psize;
  220.                 if (b_planes>1) {
  221.                     /* select colour for plane */
  222.                     fprintf(outfile,"\033r");
  223.                     (void) fputc((char)necpcolor[plane],outfile);
  224.                 }
  225.                 /* select plotter graphics mode (square pixels) */
  226.                 fprintf(outfile,"\r\033*\047");
  227.                 (void) fputc((char)((b_xsize*3)%256),outfile);
  228.                 (void) fputc((char)((b_xsize*3)/256),outfile);
  229.                 for (x=0; x<b_xsize; x++) {
  230.                     column8= (unsigned int)(*((*b_p)[j+offset]+x));
  231.                     column24=0;
  232.                     if (column8&0x01) column24|=(long)0x000007;
  233.                     if (column8&0x02) column24|=(long)0x000038;
  234.                     if (column8&0x04) column24|=(long)0x0001c0;
  235.                     if (column8&0x08) column24|=(long)0x000e00;
  236.                     if (column8&0x10) column24|=(long)0x007000;
  237.                     if (column8&0x20) column24|=(long)0x038000;
  238.                     if (column8&0x40) column24|=(long)0x1c0000;
  239.                     if (column8&0x80) column24|=(long)0xe00000;
  240.                     column1 = (char) ( column24      & (long)0xff);
  241.                     column2 = (char) ((column24>>8)  & (long)0xff);
  242.                     column3 = (char) ((column24>>16) & (long)0xff);
  243.                     (void) fputc(column3,outfile);
  244.                     (void) fputc(column2,outfile);
  245.                     (void) fputc(column1,outfile);
  246.                     (void) fputc(column3,outfile);
  247.                     (void) fputc(column2,outfile);
  248.                     (void) fputc(column1,outfile);
  249.                     (void) fputc(column3,outfile);
  250.                     (void) fputc(column2,outfile);
  251.                     (void) fputc(column1,outfile);
  252.                 }
  253.             }
  254.     }
  255.     fprintf(outfile,"\r\033l");
  256.     (void) fputc('\0',outfile);                /* set left margin to 0 */
  257.     if (b_planes > 1) {
  258.         fprintf(outfile,"\033r");
  259.         (void) fputc('\0',outfile);                /* set color to black */
  260.     }
  261. #ifdef PC
  262.     fprintf(stderr,"Print using: COPY /B\n");
  263. #endif
  264. #ifdef vms
  265.     fflush_binary();
  266. #endif
  267. }
  268.  
  269. /* output file must be binary mode for nec_dump */
  270. nec_draft_dump()
  271. {
  272. unsigned int x;
  273. unsigned int plane,offset;
  274. int j;
  275.     fprintf(outfile,"\033P\033l\005\r");  /* 10cpi, left margin 5 char */
  276.     for (j=(b_ysize/8)-1;j>=0;j--) {
  277.             fprintf(outfile,"\033J\030");  /* 24/180" line feed */
  278.             for (plane=0; plane<b_planes; plane++) {
  279.                 offset=plane*b_psize;
  280.                 if (b_planes>1) {
  281.                     /* select colour for plane */
  282.                     fprintf(outfile,"\033r");
  283.                     (void) fputc((char)necpcolor[plane],outfile);
  284.                 }
  285.                 /* select plotter graphics mode (square pixels) */
  286.                 fprintf(outfile,"\r\033*");
  287.                 (void) fputc('\0',outfile);
  288.                 (void) fputc((char)(b_xsize%256),outfile);
  289.                 (void) fputc((char)(b_xsize/256),outfile);
  290.                 for (x=0; x<b_xsize; x++) {
  291.                     (void) fputc( (char)(*((*b_p)[j+offset]+x)), outfile );
  292.                 }
  293.             }
  294.     }
  295.     fprintf(outfile,"\r\033l");
  296.     (void) fputc('\0',outfile);                /* set left margin to 0 */
  297.     if (b_planes > 1) {
  298.         fprintf(outfile,"\033r");
  299.         (void) fputc('\0',outfile);                /* set color to black */
  300.     }
  301. #ifdef PC
  302.     fprintf(stderr,"Print using: COPY /B\n");
  303. #endif
  304. }
  305.  
  306. #endif /* NEC */
  307.  
  308. #ifdef STARC
  309. /* The following Star color driver uses generic bit mapped graphics
  310.    routines to build up a bit map in memory. */
  311. /* Star Color changes made by William Wilson, wew@naucse.cse.nau.edu */
  312. /* On PC, print using 'copy file /b lpt1:', do NOT use 'print' */
  313. /* STARC_init changes outfile to binary mode on PC's */
  314.  
  315. #define STARCXMAX    512 
  316. #define STARCYMAX    384
  317.  
  318. #define STARCXLAST (STARCXMAX - 1)
  319. #define STARCYLAST (STARCYMAX - 1)
  320.  
  321. #define STARCVCHAR        FNT5X9_VCHAR      
  322. #define STARCHCHAR        FNT5X9_HCHAR        
  323. #define STARCVTIC        6
  324. #define STARCHTIC        6
  325.  
  326. /* plane 0=black, 1=cyan(blue), 2=magenta(red), 3=yellow */
  327. static unsigned int STARCcolor[] = {1,8,4,2,10,12,6,14};
  328. static unsigned int STARCpcolor[]= {0,2,1,4};
  329.  
  330. STARCinit()
  331. {
  332. #ifdef PC
  333.     reopen_binary();
  334. #endif
  335. #ifdef vms
  336.     reopen_binary();
  337. #endif
  338. }
  339.  
  340.  
  341. STARCgraphics()
  342. {
  343.     b_charsize(FNT5X9);
  344.     b_makebitmap((unsigned int)(STARCXMAX*xsize),
  345.                  (unsigned int)(STARCYMAX*ysize),4);
  346. }
  347.  
  348.  
  349. STARCtext()
  350. {
  351.     STARC_dump();
  352.     b_freebitmap();
  353. }
  354.  
  355. STARClinetype(linetype)
  356. int linetype;
  357. {
  358.     if (linetype>=6)
  359.         linetype %= 6;
  360.     b_setvalue(STARCcolor[linetype+2]);
  361. }
  362.  
  363.  
  364. #define STARCmove b_move
  365. #define STARCvector b_vector
  366. #define STARCput_text b_put_text
  367. #define STARC_text_angle b_text_angle
  368.  
  369. STARCreset()
  370. {
  371. #ifdef vms
  372.     fflush_binary();
  373. #endif
  374. }
  375.  
  376.  
  377. /* output file must be binary mode for STARC_dump */
  378. STARC_dump()
  379. {
  380. unsigned int x;
  381. unsigned int plane,offset;
  382. int j;
  383.     for (j=(b_ysize/8)-1;j>=0;j--) {
  384.         fprintf(outfile,"\033J\030");    /* line feed 8/72" = 8 dots */
  385.         for (plane=0; plane<b_planes; plane++) {
  386.             offset=plane*b_psize;
  387.             if (b_planes>1) {
  388.                 /* select colour for plane */
  389.                 fprintf(outfile,"\033r");
  390.                 (void) fputc((char)STARCpcolor[plane],outfile);
  391.             }
  392.             /* select plotter graphics mode (square pixels) */
  393.             fprintf(outfile,"\r\033*\005");
  394.             (void) fputc((char)(b_xsize%256),outfile);
  395.             (void) fputc((char)(b_xsize/256),outfile);
  396.             for (x=0; x<b_xsize; x++) {
  397.                 (void) fputc( (char)(*((*b_p)[j+offset]+x)), outfile );
  398.             }
  399.         }
  400.     }
  401.     if (b_planes > 1) {
  402.         fprintf(outfile,"\033r");
  403.         (void) fputc('\0',outfile);                /* set color to black */
  404.     }
  405. #ifdef PC
  406.     fprintf(stderr,"Print using: COPY /B\n");
  407. #endif
  408. }
  409.  
  410. #endif /* STARC */
  411.  
  412.  
  413. #ifdef EPS60
  414.  
  415. /* make the total dimensions 8 inches by 5 inches */
  416. #define EPS60XMAX    480
  417. #define EPS60YMAX    360
  418.  
  419. #define EPS60XLAST (EPS60XMAX - 1)
  420. #define EPS60YLAST (EPS60YMAX - 1)
  421.  
  422. EPS60graphics()
  423. {
  424.     b_charsize(FNT5X9);
  425.     b_makebitmap((unsigned int)(EPS60XMAX*xsize),
  426.                  (unsigned int)(EPS60YMAX*ysize),1);
  427. }
  428.  
  429.  
  430. EPS60text()
  431. {
  432.     eps60_dump();
  433.     b_freebitmap();
  434. }
  435.  
  436.  
  437.  
  438. /* output file must be binary mode for eps60_dump */
  439. eps60_dump()
  440. {
  441.   register unsigned int x;
  442.   int j;
  443.     fprintf(outfile,"\033%c\030",'3'); /* set line spacing 24/216" = 8 dots */
  444.     for (j=(b_ysize/8)-1; j>=0; j--) {
  445.         /* select printer graphics mode 'K' */
  446.         fprintf(outfile,"\r\n\033K");
  447.         (void) fputc((char)(b_xsize%256),outfile);
  448.         (void) fputc((char)(b_xsize/256),outfile);
  449.         for (x=0; x<b_xsize; x++) {
  450.             (void) fputc( (char)(*((*b_p)[j]+x)), outfile );
  451.         }
  452.     }
  453.     fprintf(outfile,"\033%c\044\r\n",'3'); /* set line spacing 36/216" = 1/6" */
  454. #ifdef PC
  455.     fprintf(stderr,"Print using: COPY /B\n");
  456. #endif
  457. }
  458.  
  459. #endif /* EPS60 */
  460.  
  461. #ifdef TANDY60
  462.  
  463. /* The only difference between TANDY60 and EPS60 is the inclusion
  464.    of codes to swap the Tandy printer into IBM mode and back
  465.    into Tandy mode.  For a Tandy already in IBM mode, use EPS60. */
  466.  
  467.  
  468. TANDY60text()
  469. {
  470. #ifdef PC
  471.     fprintf(stderr, "Inserting Tandy/IBM mode conversion codes\n");
  472. #endif
  473.     /* Switch to IBM mode, and leave 3 inches above the plot so as
  474.        to get rough vertical centring on the page.  Perform the
  475.        centring by setting 1" line feeds and issuing 3 of them. */
  476.     fprintf(outfile, "\033!\033%c%c\n\n\n", '3',216);
  477.     eps60_dump();
  478.     b_freebitmap();
  479.     /* A form feed must be sent before switching back to Tandy mode,
  480.        or else the form setting will be messed up. */
  481.     fprintf(outfile, "\f\033!");
  482. }
  483.  
  484.  
  485. #endif  /* TANDY60 */
  486.